package com.demo01.demo.Repository;
import com.demo01.demo.entity.OrderTable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface OrderRepository extends JpaRepository<OrderTable,String> {
    @Query(value = "select * from  ordertable where if(?1!='',username= ?1,true) and if(?2!='',drinkid= ?2,true) and if(?3!='',drinkname= ?3,true) and if(?4!='',drinkinfo= ?4,true) and if(?5!='',drinkprice= ?5,true) and if(?6!='',drinknum= ?6,true) and if(?7!='',orderid= ?7,true)  and if(?8!='',pickid= ?8,true)  and if(?9!='' and ?10!='',ordertime between ?9 and ?10,true) ",nativeQuery = true)
    public Page<OrderTable> find(String sql1, String sql2, String sql3, String sql4,String sql5, String sql6, String sql7,String sql8,String sql9,String sql10,Pageable pageable);
    @Query(value = "select count(distinct orderid) from ordertable where ordertime between ?1 and ?2",nativeQuery = true)
    public int findOrdernum(String sql1,String sql2);
    @Query(value = "select count(distinct orderid) from ordertable",nativeQuery = true)
    public int countorder();
    @Query(value = "select * from ordertable where ordertime between ?1 and ?2",nativeQuery = true)
    public List<OrderTable> findtodaysale(String sql1,String sql2);
    @Query(value = "select * from  ordertable where if(?1!='',username= ?1,true) and if(?2!='',drinkid= ?2,true) and if(?3!='',drinkname= ?3,true) and if(?4!='',drinkinfo= ?4,true) and if(?5!='',drinkprice= ?5,true) and if(?6!='',drinknum= ?6,true) and if(?7!='',orderid= ?7,true)  and if(?8!='',pickid= ?8,true)  and if(?9!='' and ?10!='',ordertime between ?9 and ?10,true) ",nativeQuery = true)
    public List<OrderTable> searchall(String sql1, String sql2, String sql3, String sql4,String sql5, String sql6, String sql7,String sql8,String sql9,String sql10);
}
